home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Samples / C++ / Direct3D / PRTPerVertex / skybox.fx < prev    next >
Encoding:
Text File  |  2004-09-27  |  1.6 KB  |  71 lines

  1. //-----------------------------------------------------------------------------
  2. // File: SkyBox.fx
  3. //
  4. // Desc: 
  5. // 
  6. // Copyright (c) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8.  
  9.  
  10. //-----------------------------------------------------------------------------
  11. // Global variables
  12. //-----------------------------------------------------------------------------
  13. float4x4 g_mInvWorldViewProjection;
  14. float g_fAlpha;
  15. float g_fScale;
  16.  
  17. texture g_EnvironmentTexture;
  18.  
  19. sampler EnvironmentSampler = sampler_state
  20.     Texture = (g_EnvironmentTexture);
  21.     MipFilter = LINEAR;
  22.     MinFilter = LINEAR;
  23.     MagFilter = POINT;
  24. };
  25.  
  26.  
  27. //-----------------------------------------------------------------------------
  28. // Skybox stuff
  29. //-----------------------------------------------------------------------------
  30. struct SkyboxVS_Input
  31. {
  32.     float4 Pos : POSITION;
  33. };
  34.  
  35. struct SkyboxVS_Output
  36. {
  37.     float4 Pos : POSITION;
  38.     float3 Tex : TEXCOORD0;
  39. };
  40.  
  41. SkyboxVS_Output SkyboxVS( SkyboxVS_Input Input )
  42. {
  43.     SkyboxVS_Output Output;
  44.     
  45.     Output.Pos = Input.Pos;
  46.     Output.Tex = normalize( mul(Input.Pos, g_mInvWorldViewProjection) );
  47.     
  48.     return Output;
  49. }
  50.  
  51. float4 SkyboxPS( SkyboxVS_Output Input ) : COLOR
  52. {
  53.     float4 color = texCUBE( EnvironmentSampler, Input.Tex )*g_fScale;
  54.     color.a = g_fAlpha;
  55.     return color;
  56. }
  57.  
  58. technique Skybox
  59. {
  60.     pass p0
  61.     {
  62.         VertexShader = compile vs_2_0 SkyboxVS();
  63.         PixelShader = compile ps_2_0 SkyboxPS();
  64.     }
  65. }
  66.  
  67.  
  68.  
  69.  
  70.